package com.bolingcavalry.crm.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dto.PasswordDTO;
import com.dto.user.FlatUserRole;
import com.dto.user.UserDTO;
import com.entity.user.User;
import com.vo.user.UserRoleListVo;
import com.vo.user.UserStatusVO;
import com.vo.PermissionVO;
import com.vo.RoleVO;
import com.vo.user.UserVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;


@Mapper
public interface UserMapper extends BaseMapper<User> {

    User auth(String username, String password);

    List<String> getRole(@Param("username")String username);

    String getPassword(@Param("username")String username);

    User selectByName(String username);

    int inserti(UserDTO user);

    Long getRoleIdByRoleName(String role);

    List<PermissionVO> getPermissionsByRoleId(Long roleId);

    void insertUserRole(@Param("userId")Long userId, @Param("roleId")Long roleId);

    List<RoleVO> getRoleAndId();

    List<String> getRoleByNickname(String receiverName);

    List<UserStatusVO> getUserStatus();

    IPage<UserVO> getByConditions(Page<UserVO> page, @Param("status") String status, @Param("username") String username, @Param("nickname") String nickname);

    void deleteurbyuserId(@Param("userId") Long userId);


    List<Long> getUserIdsByNickName(List<String> receiverName);

    Integer countByStatus(@Param("status") String status);


    User checkOpenid(String openid);

    List<String> getUserNamesByUserId(List<Long> receiverId);

    UserVO getUserVO(String username);

    List<Long> getRoleIdsByUserId(Long id);

    List<String> getRoleNameByUserId(Long id);

    void updatePassword(PasswordDTO passwordDTO);

    List<Long> getUserIdsByNamemohu(String receiverName);

    List<Long> getUserIdsByRoleId(Long roleId);

    List<Long> getUserIdsByRoleName(String roleName);

    Long getUserIdByUserName(String currentUsername);

    List<FlatUserRole> getUserList(String roleName);

    List<FlatUserRole> getUserListAll();

    List<String> getNicknameAll();

    /**
     * 根据用户ID获取openid
     */
    String selectOpenidByUserId(@Param("userId") Long userId);

    /**
     * 根据角色ID获取用户openid列表
     */
    List<String> selectOpenidsByRoleId(@Param("roleId") Long roleId);

    /**
     * 获取所有用户openid
     */
    List<String> selectAllOpenids();
}
